import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios请求拦截
// 在request拦截器中显示进度条
axios.interceptors.request.use(config => {
    NProgress.start()
    config.headers.authorization = window.sessionStorage.getItem('token')
    return config
})
// 在response拦截器中显示进度条
axios.interceptors.response.use(config => {
    NProgress.done()
    return config
})
// 将axios挂载到vue
Vue.prototype.$http = axios

Vue.use(ElementUI)
Vue.config.productionTip = false

// 注册树形表格插件
Vue.use(TreeTable)

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')
